package io.gitee.xyuesheng.day07;

import org.junit.Test;

import java.io.File;

public class HomeFiles {
    @Test
    public void testFileIterator2() {
        String dir = "D:\\RJ\\WJ\\HT\\day0730-01-java\\视频";
        listDirectory(new File(dir));
    }

    //传入一个目录，返回目录下面的子目录和文件
    public void listDirectory(File file) {
        File[] files = file.listFiles();

        for (int i = 0; i < files.length; i++) {
            int len = (int) (files[i].length());
            if (len > 1024 * 1024) {
                System.out.println(files[i].getAbsolutePath());
                if (files[i].isDirectory()) {//是目录
                    listDirectory(files[i]);
                    System.out.print("目录***");
                }
            }

        }

    }

}
